
package com.ami.kvm.jviewer.soc.video;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class VideoHeader {
	public static final short VIDEO_HDR_SIZE = 86;
	short iEngVersion;
	short wHeaderLen;
	public short SourceMode_X;
	public short SourceMode_Y;
	short SourceMode_ColorDepth;
	short SourceMode_RefreshRate;
	byte SourceMode_ModeIndex;
	public short DestinationMode_X;
	public short DestinationMode_Y;
	short DestinationMode_ColorDepth;
	short DestinationMode_RefreshRate;
	byte DestinationMode_ModeIndex;
	int FrameHdr_StartCode;
	int FrameHdr_FrameNumber;
	short FrameHdr_HSize;
	short FrameHdr_VSize;
	int[] FrameHdr_Reserved = new int[2];

	public byte FrameHdr_CompressionMode;

	public byte FrameHdr_JPEGScaleFactor;

	public byte FrameHdr_JPEGTableSelector;

	public byte FrameHdr_JPEGYUVTableMapping;

	public byte FrameHdr_SharpModeSelection;

	public byte FrameHdr_AdvanceTableSelector;

	public byte FrameHdr_AdvanceScaleFactor;
	public int FrameHdr_NumberOfMB;
	public byte FrameHdr_RC4Enable;
	public byte FrameHdr_RC4Reset;
	public byte Mode420;
	public byte InfData_DownScalingMethod;
	public byte InfData_DifferentialSetting;
	public short InfData_AnalogDifferentialThreshold;
	public short InfData_DigitalDifferentialThreshold;
	byte InfData_ExternalSignalEnable;
	public byte InfData_AutoMode;
	public byte InfData_VQMode;
	int CompressData_SourceFrameSize;
	public int CompressData_CompressSize;
	int CompressData_HDebug;
	int CompressData_VDebug;
	byte InputSignal;
	short Cursor_XPos;
	short Cursor_YPos;

	public void VideoHeader() {
	}

	public byte[] set(ByteBuffer paramByteBuffer) {
		int i = paramByteBuffer.limit();

		if (i == 86) {
			return null;
		}
		if (i > 86) {
			i -= 86;
		}
		byte[] arrayOfByte = new byte[i];
		paramByteBuffer.rewind();
		paramByteBuffer.order(ByteOrder.LITTLE_ENDIAN);

		this.iEngVersion = paramByteBuffer.getShort();
		this.wHeaderLen = paramByteBuffer.getShort();

		this.SourceMode_X = paramByteBuffer.getShort();
		this.SourceMode_Y = paramByteBuffer.getShort();
		this.SourceMode_ColorDepth = paramByteBuffer.getShort();
		this.SourceMode_RefreshRate = paramByteBuffer.getShort();
		this.SourceMode_ModeIndex = paramByteBuffer.get();

		this.DestinationMode_X = paramByteBuffer.getShort();
		this.DestinationMode_Y = paramByteBuffer.getShort();
		this.DestinationMode_ColorDepth = paramByteBuffer.getShort();
		this.DestinationMode_RefreshRate = paramByteBuffer.getShort();
		this.DestinationMode_ModeIndex = paramByteBuffer.get();

		this.FrameHdr_StartCode = paramByteBuffer.getInt();
		this.FrameHdr_FrameNumber = paramByteBuffer.getInt();
		this.FrameHdr_HSize = paramByteBuffer.getShort();
		this.FrameHdr_VSize = paramByteBuffer.getShort();
		this.FrameHdr_Reserved[0] = paramByteBuffer.getInt();
		this.FrameHdr_Reserved[1] = paramByteBuffer.getInt();
		this.FrameHdr_CompressionMode = paramByteBuffer.get();
		this.FrameHdr_JPEGScaleFactor = paramByteBuffer.get();
		this.FrameHdr_JPEGTableSelector = paramByteBuffer.get();
		this.FrameHdr_JPEGYUVTableMapping = paramByteBuffer.get();
		this.FrameHdr_SharpModeSelection = paramByteBuffer.get();
		this.FrameHdr_AdvanceTableSelector = paramByteBuffer.get();
		this.FrameHdr_AdvanceScaleFactor = paramByteBuffer.get();
		this.FrameHdr_NumberOfMB = paramByteBuffer.getInt();
		this.FrameHdr_RC4Enable = paramByteBuffer.get();
		this.FrameHdr_RC4Reset = paramByteBuffer.get();
		this.Mode420 = paramByteBuffer.get();

		this.InfData_DownScalingMethod = paramByteBuffer.get();
		this.InfData_DifferentialSetting = paramByteBuffer.get();
		this.InfData_AnalogDifferentialThreshold = paramByteBuffer.getShort();
		this.InfData_DigitalDifferentialThreshold = paramByteBuffer.getShort();
		this.InfData_ExternalSignalEnable = paramByteBuffer.get();
		this.InfData_AutoMode = paramByteBuffer.get();
		this.InfData_VQMode = paramByteBuffer.get();

		this.CompressData_SourceFrameSize = paramByteBuffer.getInt();
		this.CompressData_CompressSize = paramByteBuffer.getInt();
		this.CompressData_HDebug = paramByteBuffer.getInt();
		this.CompressData_VDebug = paramByteBuffer.getInt();

		this.InputSignal = paramByteBuffer.get();
		this.Cursor_XPos = paramByteBuffer.getShort();
		this.Cursor_YPos = paramByteBuffer.getShort();
		try {
			paramByteBuffer.get(arrayOfByte);
		} catch (Exception localException) {
			System.out.println("AST VIDEO HDR ");
			localException.printStackTrace();
		}

		return arrayOfByte;
	}
}
